package com.example.controller;

import com.example.pojo.*;
import com.example.service.TeacherSecondPageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@CrossOrigin
public class TeacherSecondPageController {

    @Autowired
    private TeacherSecondPageService teacherSecondPageService;
    @GetMapping("/loadScores")
    public ScoreResult loadScores(Integer teacherId){
        log.info("加载教工号为{}教师所教的学生信息",teacherId);
        List<Student> studentList = teacherSecondPageService.loadScores(teacherId);
        return ScoreResult.success(studentList);
    }
    @PostMapping("/editScore")
    public Result editScore(@RequestBody Score score){
        log.info("修改学生成绩信息:{}",score);
        return teacherSecondPageService.editScore(score);
    }

    @DeleteMapping("/deleteScore")
    public Result deleteScore(@RequestBody Score score){
        log.info("删除学生成绩信息:{}",score);
        return teacherSecondPageService.deleteScore(score);
    }

}
